<tc_include file="Public:head" />
<body ontouchstart style="background: #f1f1f1;">
<div class="container" id="container">
    <div class="page">
        <div class="page__bd" style="height: 100%; overflow: hidden;">
            <div class="weui-tab">
                <div class="weui-tab__panel">
                    <div class="weui-cells setup-list">
                        <a class="weui-cell weui-cell_access" href="javascript:;">
                            <div class="weui-cell__bd">
                                <p>头像</p>
                            </div>
                            <div class="weui-cell__ft"><img src="{$member['head_img']}"></div>
                        </a>
                        <a class="weui-cell weui-cell_access" href="javascript:;" id="modifyName">
                            <div class="weui-cell__bd">
                                <p>姓名</p>
                            </div>
                            <div class="weui-cell__ft" id="lbl_name">{$member['member_name_chn']}</div>
                        </a>
                        <a class="weui-cell weui-cell_access" href="javascript:;" id="modifyNickName">
                            <div class="weui-cell__bd">
                                <p >昵称</p>
                            </div>
                            <div class="weui-cell__ft" id="lbl_nickname">{$member['nickname']}</div>
                        </a>
                        <a class="weui-cell weui-cell_access" href="javascript:;" id="saxPicker">
                            <div class="weui-cell__bd">
                                <p>性别</p>
                            </div>
                            <div class="weui-cell__ft" id="lbl_sex">{$member['sex']=='F'?'女':'男'}</div>
                        </a>
                        <a class="weui-cell weui-cell_access" href="javascript:;">
                            <div class="weui-cell__bd">
                                <p>手机号</p>
                            </div>
                            <div class="weui-cell__ft">{$member['telephone']}</div>
                        </a>
                        <a class="weui-cell weui-cell_access" href="{:U('member/modifyPwd')}">
                            <div class="weui-cell__bd">
                                <p>密码管理</p>
                            </div>
                            <div class="weui-cell__ft"></div>
                        </a>

                        <a class="weui-cell weui-cell_access" href="{:U('public/doLogout')}">
                            <div class="weui-cell__bd">
                                <p>退出登录</p>
                            </div>
                            <div class="weui-cell__ft"></div>
                        </a>


                    </div>
                </div>
                <tc_include file="Public:menu" />
            </div>
        </div>
    </div>
</div>
<div id="dialogs">
    <!--BEGIN 修改姓名-->
    <div class="js_dialog" id="modifyNameDialog" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog">
            <div class="weui-dialog__hd"><strong class="weui-dialog__title">修改姓名</strong></div>
            <div class="weui-dialog__bd">
                <input class="weui-input" type="text" placeholder="请输入姓名" value="" id="Name">
            </div>
            <div class="weui-dialog__ft">
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary" id="modifyNameOk">确认</a>
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default">取消</a>
            </div>
        </div>
    </div>
    <!--END 修改姓名-->
    <!--BEGIN 修改昵称-->
    <div class="js_dialog" id="modifyNickNameDialog" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog">
            <div class="weui-dialog__hd"><strong class="weui-dialog__title">修改昵称</strong></div>
            <div class="weui-dialog__bd">
                <input class="weui-input" type="text" placeholder="请输入昵称" value="" id="NickName">
            </div>
            <div class="weui-dialog__ft">
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary" id="modifyNickNameOk">确认</a>
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default">取消</a>
            </div>
        </div>
    </div>
    <!--END 修改昵称-->
</div>
<tc_include file="Public:footer" />
<script>
    //修改性别
    var saxData=[{
        label: '男',
        value: 'M'
    }, {
        label: '女',
        value: 'F'
    }];
    $('#saxPicker').on('click', function () {
        var _this=$(this).children(".weui-cell__ft");
        weui.picker(saxData, {
            defaultValue:['{$member["sex"]}'],
            onChange: function (result) {
                //console.log(result);
            },
            onConfirm: function (result) {
                saxData.forEach(function(item,index){
                    if(item.value==result){
                        $.post("{:U('member/doModify')}",{sex:item.value},function (data) {
                            if(data.code==200){
                                _this.html(item.label);
                            }
                        });
                    }
                })
            }
        });
    });
    //关闭弹窗
    $('#dialogs').on('click', '.weui-dialog__btn', function(){
        $(this).parents('.js_dialog').fadeOut(0);
    });
    //修改姓名
    $('#modifyName').on('click', function(){
        var name = $("#lbl_name").html();
        $("#Name").val(name);
        $("#modifyNameDialog").fadeIn(0);
    });
    $("#modifyNameOk").on("click",function(){
        var name = $("#Name").val();
        $.post("{:U('member/doModify')}",{member_name_chn:name},function (data) {
            if(data.code==200){
                $('#modifyName').children(".weui-cell__ft").html($("#Name").val());
            }
        });

    });

    //修改昵称
    $('#modifyNickName').on('click', function(){
        var NickName = $("#lbl_nickname").html();
        $("#NickName").val(NickName);
        $("#modifyNickNameDialog").fadeIn(0);
    });
    $("#modifyNickNameOk").on("click",function(){
        var name = $("#NickName").val();
        $.post("{:U('member/doModify')}",{nickname:name},function (data) {
            if(data.code==200){
                $('#modifyNickName').children(".weui-cell__ft").html($("#NickName").val())
            }
        });

    })
</script>
